package com.xiaotu.dao.pgsql;

import com.xiaotu.entity.ActorAwardModel;
import com.xiaotu.entity.StarDeleteRecordModel;
import com.xiaotu.entity.StarModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author zhangxiao
 * @create 2021-09-23 9:08
 */
public interface PgsqlStarMapper {

    @Select("<script>" +
            " SELECT  " +
            "  t1.starid,  " +
            "  t2.NAME,  " +
            "  array_to_string(t2.alias,',') alias,  " +
            "  array_to_string(t2.occupation, ',') occupation,  " +
            "  t1.country,  " +
            "  t1.area,  " +
            "  t2.sex,  " +
            "  t2.height,  " +
            "  t2.weight,  " +
            "  t1.bloodtype,  " +
            "  t1.nation,  " +
            "  t2.school,  " +
            "  t1.born,  " +
            "  t2.birthday,  " +
            "  t1.constellation,  " +
            "  t1.interest,  " +
            "  t1.introduction,  " +
            "  t2.brokeragefirm,  " +
            "  array_to_string( t1.works, ',' ) works,  " +
            "  t1.awards,  " +
            "  t2.imagesurl,  " +
            "  t1.createtime,  " +
            "  t1.lastupdatetime,  " +
            "  t1.starnameid,  " +
            "  t1.dataweight,  " +
            "  t1.representativework,  " +
            "  t1.representativeworkid,  " +
            "  t1.uniquename,  " +
            "  t1.repeat,  " +
            "  t1.weibourl,  " +
            "  t1.agent,  " +
            "  t1.agentphone,  " +
            "  array_to_string(t1.label, ',') AS label,  " +
            "  t1.datastate,  " +
            "  t1.datasourceid,  " +
            "  t1.deathday,  " +
            "  t1.foreignersign,  " +
            "  t1.baikeurl,  " +
            "  t1.doubanurl   " +
            "  FROM  " +
            "   basicinfo.tab_star_info_to_tencent t2  " +
            "   INNER JOIN basicinfo.tab_star_info t1 ON t1.starid = t2.starid   " +
            "  WHERE  " +
            "  t1.lastupdatetime :: DATE = '${specifyDate}' " +
            "</script>")
    List<StarModel> needSyncs(@Param("specifyDate") String specifyDate);

    @Select("<script>" +
            " SELECT * FROM basicinfo.tab_actor_award " +
            "</script>")
    List<ActorAwardModel> getStarAwards();

    @Select("<script>" +
            " SELECT * FROM basicinfo.tab_star_delete_record " +
            "</script>")
    List<StarDeleteRecordModel> getStarDeleteRecords();

}
